package com.yuwei.splash

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.CountDownTimer
import android.widget.TextView
import com.alibaba.android.arouter.launcher.ARouter
import com.yuwei.router.RoutePath

class SplashActivity : AppCompatActivity() {
    lateinit var countDownTimer: CountDownTimer
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash)
        val textView = findViewById<TextView>(R.id.tv)
        countDownTimer = object : CountDownTimer(4000, 1000) {
            override fun onTick(millisUntilFinished: Long) {
                textView.text = "跳过 " + millisUntilFinished / 1000+"s"
            }

            override fun onFinish() {
                ARouter.getInstance().build(RoutePath.LOGIN_ACTIVITY).navigation()
                finish()
            }
        }.start()
        textView.setOnClickListener {
            countDownTimer.cancel()
            ARouter.getInstance().build(RoutePath.LOGIN_ACTIVITY).navigation()
            finish()
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        countDownTimer.cancel()
    }
}